/**
 * 用户管理
 */
const express = require('express')
const user = require('../../middleware/user')

const accountApp = express()

accountApp.get('/', (req, res) => {
    res.render('admin/account/index', { user: req.user })
})
accountApp.post('/edit', user.edit, (req, res) => {
    if (req.affectedRows > 0) {
        res.render('admin/alert', { code: true, title: '成功提示', message: '修改成功，重新登陆更新数据', url: '/user/logout'})
    } else {
        res.render('admin/alert', { code: true, title: '失败提示', message: '修改失败', url: '/admin/account/'})
    }
})

module.exports = accountApp